<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/style.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-3.2.1.js">
	
</script>
<title>八维贴吧</title>
</head>
<body>
	<!-- 包含header.jsp -->
	<jsp:include page="/WEB-INF/view/common/header.jsp" />

	<!-- ///////////////////////////////自己开发部分中间部分开始/////////////////////////// -->


	 <div class="container">
        <div class="row">
            <div class="col12">
                    <div class="card" >
                        <div class="card-header">
                            <b>${topic.title} </b>
                        </div>
                        <div class="card-body">
                            <table>
                                <c:forEach items="${topic.replys}" var="reply">
                                <tr>
                                    <td width="20%" class="bg-light">
                                        <p align="center"><b>${reply.floor}楼</b></p>
                                        <p align="center">${reply.floor==1 ? "作者":"回复人"} ：${reply.user.nickName}</p>
                                        <p align="center"><fmt:formatDate value="${reply.updated}" pattern="yyyy-MM-dd HH:ss:mm"/> </p>
                                    </td>
                                    <td>
                                                ${reply.content}
                                    </td>
                                </tr>
                                </c:forEach>
                                <tr>
                                    <td width="20%" class="bg-light">
                                        <p align="center"><b>${topic.floors + 1}楼</b></p>
                                        <p align="center">我要回复</p>
                                    </td>
                                    <td>
                                        <form action="${pageContext.request.contextPath }/replying" method="post">
                                             <input type="hidden"  name="floor"  value="${topic.floors + 1}">
                                             <input type="hidden"  name="topic.id"  value="${topic.id}">
                                            <c:choose>
                                                <c:when test="${LOGIN_USER!= null}">
                                                <textarea id="content" name="content">
                                                </textarea>
                                                 <p align="center"><button type="submit" class="btn btn-danger">提交</button></p>
                                                </c:when>
                                                <c:otherwise>
                                                    <textarea id="content" name="content" disabled="disabled" onfocus="alert('您没有登录.');this.value=''"></textarea>
                                                    <p align="center"><button type="button" class="btn" disabled="disabled">请先登录再回复...</button></p>
                                                </c:otherwise>
                                            </c:choose>
                                        </form>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
            </div>
        </div>
    </div>






	<!-- ///////////////////////////////自己开发部分中间部分开始/////////////////////////// -->

	<!-- jsp包含尾部footer.jsp -->
	<jsp:include page="/WEB-INF/view/common/footer.jsp" />

	<script type="text/javascript">
		function searchData(pageNum) {
			$("#pageNum").val(pageNum);
			$("#pageFrm").submit();
		}
	</script>

</body>
</html>